package edu.qichen.onlineBlog.likes.controller;

import edu.qichen.onlineBlog.framework.AuthAccess;
import edu.qichen.onlineBlog.framework.DataResult;
import edu.qichen.onlineBlog.framework.OperationAnnotation;
import edu.qichen.onlineBlog.likes.dto.LikesBlogsUserPageDto;
import edu.qichen.onlineBlog.likes.dto.PageLikesReq;
import edu.qichen.onlineBlog.likes.dto.PageLikesRes;
import edu.qichen.onlineBlog.likes.service.LikesService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 功能:
 * 作者:程序员欧阳子韩
 * 日期:2024/5/2 16:40
 */
@RestController
@RequestMapping("/likes")
@Tag(name = "点赞接口")
public class LikesController {
    @Autowired
    private LikesService likesService;

    /**
     * 获取点赞信息
     *
     * @param pageLikesReq -
     * @return -
     */
    @Operation(summary = "获取点赞信息")
    @PostMapping("/queryLikes")
    @AuthAccess
    public DataResult<PageLikesRes<LikesBlogsUserPageDto>> queryLikes(@RequestBody PageLikesReq pageLikesReq) {
        return DataResult.success(likesService.queryLikes(pageLikesReq));
    }

    /**
     * 删除点赞信息
     *
     * @param id -
     * @return -
     */
    @Operation(summary = "删除点赞信息")
    @DeleteMapping("/deleteById")
    @OperationAnnotation(content = "删除点赞信息", sysType = 0, opType = 2, action = "成功")
    public DataResult<Boolean> deleteById(Integer id, HttpServletRequest request) {
        return DataResult.success(likesService.deleteById(id,request));
    }
}
